<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:composite="http://java.sun.com/jsf/composite"
      xmlns:f="http://java.sun.com/jsf/core">
    <!-- INTERFACE -->
    <composite:interface>

        <composite:attribute name="titulo" required="true"/>
        <composite:attribute name="buttonText" required="true" default="Criar"/>
        <composite:attribute name="onclick_button_update" />
        <composite:attribute name="onclick_sair_javascript" />
        <composite:attribute name="buttonAction" required="true"
                             method-signature="java.lang.String action()"/>
    </composite:interface>


    <!-- IMPLEMENTATION -->
    <composite:implementation>
            <h:form id="tituloForm">
                <p:panel header="Titulo"  >
                                 <script type="text/javascript">
                                     apply_price_format('.valor');
                                     apply_quant_format('.quant');
                                 </script>
                                <h:panelGrid columns="2">
                                    <h:outputText value="Origem:" styleClass="formShortLabel"/>
                                    <p:inputText value="#{cc.attrs.titulo.obra}" disabled="true" size="66"/>
                                    <h:outputText value="Fornecedor:" styleClass="formShortLabel"/>
                                    <p:inputText value="#{cc.attrs.titulo.fornecedor}" disabled="true" size="66"/>
                                </h:panelGrid>

                                <h:panelGrid columns="4">
                                    <h:outputText value="Numero Documento:" styleClass="formShortLabel"/>
                                    <p:inputText id="numeroNota" value="#{cc.attrs.titulo.numeroDocumento}" disabled="true"/>

                                    <h:outputText value="Data movimento:" styleClass="formShortLabel"/>
                                    <p:calendar value="#{cc.attrs.titulo.emissao}" disabled="true" />

                                    <h:outputText value="Data vencimento:" styleClass="formShortLabel"/>
                                    <p:calendar value="#{cc.attrs.titulo.vencimento}" disabled="true"/>

                                    <h:outputText value="Valor:" styleClass="formShortLabel"/>
                                    <p:inputText value="#{cc.attrs.titulo.valor}" styleClass="valor"
                                          converter="monetaryConverter" disabled="true" />
                                </h:panelGrid>
                                   <p:watermark for="numeroNota" value="Numero nota" />
                                <h:panelGrid columns="3">
                                    <h:outputText value="Pago:" styleClass="formShortLabel" />
                                    <p:selectBooleanCheckbox  value="#{cc.attrs.titulo.isPago}" />
                                    <h:outputText value="Marcar se estiver pago."/>
                                </h:panelGrid>

                                <h:panelGrid columns="2">
                                   <h:outputText value="Tipo pagamento" styleClass="formShortLabel" />
                                   <p:selectOneMenu value="#{cc.attrs.titulo.tipoPagamento}" style="width: 182px" converter="tipoPagamentoConverter" disabled="true" >
                                       <f:selectItem itemLabel="Escolha o tipo de pagamento" itemValue="" />
                                       <f:selectItems value="#{contasPagarBean.tipoPagamentos}" var="tipos"
                                                      itemLabel="#{tipos.name}" itemValue="#{tipos}"/>
                                   </p:selectOneMenu>
                                </h:panelGrid>

                                <h:panelGrid columns="2">
                                    <h:outputText value="Referente:" styleClass="formShortLabel"/>
                                    <p:inputTextarea value="#{cc.attrs.titulo.referente}" autoResize="false" cols="51"/>
                                </h:panelGrid>
                                <h:panelGrid columns="2">
                                    <h:outputText value="Obs:" styleClass="formShortLabel"/>
                                    <p:inputTextarea value="#{cc.attrs.titulo.obs}" autoResize="false" cols="51"/>
                                </h:panelGrid>

                            </p:panel>
                            <p:panel header="Conta"  >
                                <h:panelGrid columns="2">
                                <h:outputText value="Banco:" styleClass="formShortLabel"/>
                                <p:selectOneMenu value="#{cc.attrs.titulo.bank}" >
                                    <f:selectItem itemLabel="Escolha um banco" itemValue="" />
                                    <f:selectItems value="#{contasPagarBean.banks}" var="b"
                                                      itemLabel="#{b.name}" itemValue="#{b}"/>
                                   </p:selectOneMenu>

                                 <h:outputText value="Agencia:" styleClass="formShortLabel"/>
                                 <p:inputText value="#{cc.attrs.titulo.agencia}" />

                                 <h:outputText value="Conta:" styleClass="formShortLabel"/>
                                 <p:inputText value="#{cc.attrs.titulo.conta}" />

                                </h:panelGrid>
                            </p:panel>
                    <p:separator />
                    <p:commandButton value="#{cc.attrs.buttonText}" action="#{cc.attrs.buttonAction}"
                                     update="#{cc.attrs.onclick_button_update}" onclick="#{cc.attrs.onclick_sair_javascript}"  />
                </h:form>
    </composite:implementation>
</html>
